let nav_uu = document.querySelector("#nav #uu")
let container_uu = document.querySelector("#container #uu")
//导航栏部分
fetch("http://chst.vip:1234/api/getbaicaijiatitle")
    .then(body => body.json())
    .then(res => {
        console.log(res);
        let el = ""
        res.result.forEach(item => {
            el += `<li titleId=${item.titleId}>${item.title}</li>`
        })
        nav_uu.innerHTML = el
    })

$("#nav #uu").on("click", "li", function () {
    let id = this.getAttribute('titleId');
    fetch("http://chst.vip:1234/api/getbaicaijiaproduct?titleid=" + id)
        .then(body => body.json())
        .then(res => {
            console.log(res);
            let el = ""
            res.result.forEach(item => {
                el += `
                <li>
                <a href="" class="clearfix im">
                <div class="img">
                ${item.productImg}
                </div>
                <div class="infoR">
                <div class="title">
                <h4>
                ${item.productName}
                </h4>
                <div class="price">
                ${item.productPrice}
                <del>
                1888.0
                </del>
                </div>
                </div>
                <div class="down">
                
                <div class="bar">
                <div class="bar_in">0%</div>
                
                </div>
                <span class="yiling">已领126张/剩余0张</span>
                <div class="click">
                <div class="left">
                点此领取优惠券
                </div>
                <div class="right">
                下单链接
                </div>
                </div>
                </div>
            </div>
            </a>
        </li>`
            })
            container_uu.innerHTML = el
            $("#container ul li a .infoR .down .bar_in").animate({
                width: "100%",
            }, 3000, "linear")
            let p = 0;
            let time = setInterval(function () {
                p++;
                $("#container ul li a .infoR .down .bar_in").html(p + "%")
                if (p === 100) {
                    clearInterval(time)
                }
            }, 25)
        })
})

fetch("http://chst.vip:1234/api/getbaicaijiaproduct?titleid=0")
    .then(body => body.json())
    .then(res => {
        console.log(res);
        let el = ""
        res.result.forEach(item => {
            el += `
            <li>
            <a href="" class="clearfix im">
            <div class="img">
            ${item.productImg}
            </div>
            <div class="infoR">
            <div class="title">
            <h4>
            ${item.productName}
            </h4>
            <div class="price">
            ${item.productPrice}
            <del>
            1888.0
            </del>
            </div>
            </div>
            <div class="down">
            
            <div class="bar">
            <div class="bar_in">0%</div>
            </div>
            
            <span class="yiling">已领126张/剩余0张</span>
            <div class="click">
            <div class="left">
            点此领取优惠券
            </div>
            <div class="right">
            下单链接
            </div>
            </div>
            </div>
        </div>
        </a>
    </li>`
        })
        container_uu.innerHTML = el
        $("#container ul li a .infoR .down .bar_in").animate({
            width: "100%",
        }, 3000, "linear")
        let p = 0;
        let time = setInterval(function () {
            p++;
            $("#container ul li a .infoR .down .bar_in").html(p + "%")
            if (p === 100) {
                clearInterval(time)
            }
        }, 25)
    })
